/***********************************************************************
 * Module:  PhoneyPlateVehicleController.java
 * Author:  Administrator
 * Purpose: Defines the Class PhoneyPlateVehicleController
 ***********************************************************************/

package ishitong.vehicleManagement.controller;

import ishitong.vehicleManagement.model.PhoneyPlateVehicleQuery;
import ishitong.common.SysCodeType;
import ishitong.common.model.SysCode;
import ishitong.commons.pagination.Pagination;
import ishitong.vehicleManagement.model.PhoneyPlateVehicle;
import ishitong.vehicleManagement.service.biz.PhoneyPlateVehicleService;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import com.ishitong.platform.common.page.Page;

/** @pdOid dd772461-67a4-4977-942b-fa2ba089647e */
@Controller
public class PhoneyPlateVehicleController extends ishitong.common.controller.ActionController {
   /** @pdOid a5930991-65f9-49fb-9521-48760a434828 */
   private static final String PHO_PLA_SCH = "vehicleManagement/phoneyPlateVehicle/phoneyPlateVehicleSearch";
   /** @pdOid 4855afb9-f4ff-4f8b-87af-b228b77cc3bb */
   private static final String PHO_PLA_SCH_LST = "vehicleManagement/phoneyPlateVehicle/phoneyPlateVehicleSearchList";
   /** @pdOid f0ba8721-b70d-4203-b34a-ba96ce565e97 */
   private static final String PHO_PLA_EDT = "vehicleManagement/phoneyPlateVehicle/phoneyPlateVehicleEdit";
   /** @pdOid 9216bd92-f9a6-4e91-bb21-ffaffc837b8f */
   private static final String PHO_PLA_VIW = "vehicleManagement/phoneyPlateVehicle/phoneyPlateVehicleView";
   /** @pdOid 832179fc-e773-4e97-948d-e25a52319c0e */
   @Autowired
   private PhoneyPlateVehicleService phoneyPlateVehicleService;
   
   /** @param request
    * @exception Exception
    * @pdOid 7fae1832-68a2-41eb-b017-8ec1693ad93d */
   @RequestMapping(value = "/showPhoneyPlateVehicleSearch.do")
   public ModelAndView handleShowPhoneyPlateVehicleSearch(HttpServletRequest request) throws Exception {
   	try {
   		Map<String, Object> model = new HashMap<>();
   
   		// 号牌种类
   		List<SysCode> lstLicencePlateKind = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.PLATE_KIND); 
   		model.put("lstLicencePlateKind", lstLicencePlateKind);
   		// 使用性质   		
   		List<SysCode> lstUseNature = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.USE_NATURE);
   		model.put("lstUseNature", lstUseNature);
   
   		// 车辆分类
   		List<SysCode> lstVehicleClassification = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.VEHICLE_SORT);
   		model.put("lstVehicleClassification", lstVehicleClassification);
   
   		// 车辆类型
   		List<SysCode> lstVehicleType = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.VEHICLE_TYPE);
   		model.put("lstVehicleType", lstVehicleType);
   
   		return new ModelAndView(PHO_PLA_SCH, model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param phoneyPlateVehicleQuery 
    * @param pagination
    * @pdOid 2432df80-ee92-4367-80e9-f067d55aa60d */
   @RequestMapping(value = "/ajaxPhoneyPlateVehicleSearchList.do")
   public ModelAndView handleAjaxFindPhoneyPlateVehicleSelectList(HttpServletRequest request, PhoneyPlateVehicleQuery phoneyPlateVehicleQuery, Pagination pagination) {
   	try {
   		Map<String, Object> model = new HashMap<>();
   		Page<PhoneyPlateVehicle> page = phoneyPlateVehicleService.findPage(phoneyPlateVehicleQuery, pagination.getPageSize(), pagination.getCurrentPage());
   		model.put("page", page);
   		return new ModelAndView(PHO_PLA_SCH_LST, model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param phoneyPlateVehicleId
    * @exception Exception
    * @pdOid 95874221-014d-41d0-9ab1-cae006575193 */
   @RequestMapping(value = "/ajaxShowPhoneyPlateVehicleEdit.do", method = RequestMethod.POST)
   public ModelAndView handleAjaxShowPhoneyPlateVehicleEdit(HttpServletRequest request, String phoneyPlateVehicleId) throws Exception {
   	try {
   		Map<String, Object> model = new HashMap<String, Object>();
   
   		// 号牌种类
   		List<SysCode> lstLicencePlateKind = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.PLATE_KIND);
   		model.put("lstLicencePlateKind", lstLicencePlateKind);
   
   		// 使用性质
   		List<SysCode> lstUseNature = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.USE_NATURE);
   		model.put("lstUseNature", lstUseNature);
   
   		// 车辆分类
   		List<SysCode> lstVehicleClassification = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.VEHICLE_SORT);
   		model.put("lstVehicleClassification", lstVehicleClassification);
   
   		// 车辆类型
   		List<SysCode> lstVehicleType = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.VEHICLE_TYPE);
   		model.put("lstVehicleType", lstVehicleType);
   
   		// 号牌颜色
   		List<SysCode> lstPlateColor = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.PLATE_COLOR);
   		model.put("lstPlateColor", lstPlateColor);
   
   		// 车身颜色
   		List<SysCode> lstVehicleColor = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.VEHICLE_COLOR);
   		model.put("lstVehicleColor", lstVehicleColor);
   
   		if(!StringUtils.isEmpty(phoneyPlateVehicleId)){
   			PhoneyPlateVehicle phoneyPlateVehicle = phoneyPlateVehicleService.findById(phoneyPlateVehicleId);
   			model.put("phoneyPlateVehicle", phoneyPlateVehicle);
   		}
   		return new ModelAndView(PHO_PLA_EDT, model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param phoneyPlateVehicle 
    * @param response
    * @exception Exception
    * @pdOid 97e0d48b-2124-4bf1-b19d-39536ac70d5a */
   @RequestMapping(value = "/ajaxSavePhoneyPlateVehicle.do",method = RequestMethod.POST)
   public void handleAjaxSavePhoneyPlateVehicle(HttpServletRequest request, PhoneyPlateVehicle phoneyPlateVehicle, HttpServletResponse response) throws Exception {
   	try {
   		phoneyPlateVehicleService.save(phoneyPlateVehicle);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   }
   
   /** @param request 
    * @param phoneyPlateVehicleId
    * @exception Exception
    * @pdOid a430943a-1d56-4f2c-bc58-e22d3b1973a7 */
   @RequestMapping(value = "/ajaxShowPhoneyPlateVehicleView.do", method = RequestMethod.POST)
   public ModelAndView handleAjaxShowPhoneyPlateVehicleView(HttpServletRequest request, String phoneyPlateVehicleId) throws Exception {
   	try {
   		Map<String, Object> model = new HashMap<String, Object>();
   		if(!StringUtils.isEmpty(phoneyPlateVehicleId)){
   			PhoneyPlateVehicle phoneyPlateVehicle = phoneyPlateVehicleService.findById(phoneyPlateVehicleId);
   			model.put("phoneyPlateVehicle", phoneyPlateVehicle);
   		}
   		return new ModelAndView(PHO_PLA_VIW,model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param phoneyPlateVehicleIds 
    * @param response
    * @exception Exception
    * @pdOid 497b5280-650f-4256-869f-9910d58ddb56 */
   @RequestMapping(value = "/ajaxDeletePhoneyPlateVehicleByIds.do", method = RequestMethod.POST)
   public void handleAjaxDeletePhoneyPlateVehicleByIds(HttpServletRequest request, String phoneyPlateVehicleIds, HttpServletResponse response) throws Exception {
   	try {
   		phoneyPlateVehicleService.delete(phoneyPlateVehicleIds);
   	} catch (Exception e) {
   		e.printStackTrace();
   	} 	
   }

}